package taskthree;

/**
 * @author wuwenfa
 */
public class ThreadOne implements Runnable {

    public final Object lock;

    public ThreadOne(Object lock) {
        this.lock = lock;
    }

    @Override
    public void run() {
        synchronized (lock) {
            while (Main.num <= 100) {
                lock.notify();
                System.out.println(Thread.currentThread().getName() + "打印：" + Main.num);
                Main.num++;
                try {
                    lock.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
